package com.wzy.netty.core.inboundhandlerandoutboundhandler;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-22  21:03
 */
public class MyServerHandler extends SimpleChannelInboundHandler<Long> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Long msg) throws Exception {
        System.out.println("从客户端读取到" + ctx.channel().remoteAddress() + "long : " + msg);

        //给客户端会送一个long
        ctx.writeAndFlush(999999L);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        ctx.close();
    }
}
